<template>
  <div>
    <h5 style="text-align:center;height:6vh;line-height:6vh">分类商品</h5>
    <div style="float:left;width:100%;height:100vh">
      <div
        @click="cart_list(item.id)"
        v-for="(item, index) in buttomlist"
        :key="index"
        class="cart_top_div"
        style="float:left"
      >
        <img :src="item.pic" width="100%" height="90%" alt />
        <div
          class="cart_p_title"
          style="width:45%;font-size:12px; height:3vh;background:rgb(240,237,212);color: #B69B72;text-align:center;line-height:3vh;"
        >{{item.name}}</div>
        <p style="color:red">￥{{item.numberOrders}}</p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      buttomlist: [],
    };
  },
  methods: {
    cart_list(id) {
      this.$router.push({
        path: "/cartlist",
        query: {
          id,
        },
      });
    },
  },
  mounted() {
    let id = this.$route.query.id;
    this.$axios
      .buttomlist({
        params: {
          categoryId: id,
        },
      })
      .then((res) => {
        // console.log(res.data.data);
        this.buttomlist = res.data.data;
      });
  },
};
</script>

<style  scoped>
.cart_top_div {
  width: 45%;
  height: 30vh;
  float: left;
  margin-left: 3%;
  margin-top: 3%;
}
.cart_p_title {
  position: absolute;
  margin-top: -6.8%;
}
</style>

